package com.jzo2o.customer.controller.agency;




import com.jzo2o.common.model.Result;
import com.jzo2o.common.utils.UserContext;
import com.jzo2o.customer.model.dto.request.AgencyCertificationAuditAddReqDTO;
import com.jzo2o.customer.model.dto.response.RejectReasonResDTO;
import com.jzo2o.customer.service.IAgencyCertificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("agencyCertificationController")
@RequestMapping("/agency/agency-certification-audit")
@Api(tags = "机构端 - 服务人员或机构相关接口")
public class AgencyCertificationController {

    @Autowired
    private IAgencyCertificationService agencyCertificationService;

    @PostMapping
    @ApiOperation("机构提交认证申请")
    public void agencyCertification(@RequestBody AgencyCertificationAuditAddReqDTO agencyCertificationAuditAddReqDTO){
        agencyCertificationService.audit(agencyCertificationAuditAddReqDTO);
    }

    @GetMapping("/rejectReason")
    @ApiOperation("查询最新的驳回原因")
    public RejectReasonResDTO rejectReason() {
        // 获取当前登录用户的企业机构ID
        Long serveProviderId = UserContext.currentUserId();
        // 调用服务层获取驳回原因
        String rejectReason = agencyCertificationService.getLatestRejectReason(serveProviderId);

        // 构建返回结果
        RejectReasonResDTO rejectReasonResDTO = new RejectReasonResDTO();
        rejectReasonResDTO.setRejectReason(rejectReason);

        return rejectReasonResDTO;
    }

}
